package com.ydche;

import com.ydche.config.MailConfig;
import com.ydche.config.MyProps;
import com.ydche.idl_output.IBiz;
import com.ydche.idl_output.RequestException;
import com.ydche.idl_output.UserProfile;
import com.ydche.redis.RedisClient;
import com.ydche.service.*;
import com.ydche.util.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserHandler implements IBiz.Iface{
    @Autowired
    IUserService userService;
    @Autowired
    MyProps props;
    @Autowired
    MailConfig mailConfig;
    @Autowired
    RedisClient redis;
    @Autowired
    ISmsService smsService;

    @Override
    public int registerByMobile(UserProfile user) throws RequestException {
        System.out.println(props.getSimpleProp());
        System.out.println(mailConfig.getUsername());
        System.out.println(mailConfig.getHost());
        try {
            System.out.println("redis read data="+redis.get("hehe"));
            redis.set("hehe", "mlgb");
            System.out.println("redis read data="+redis.get("hehe"));
        }catch (Exception e){

        }
        return userService.registerByMobile(user);
    }

    @Override
    public UserProfile getUserByMobile(String mobile) throws RequestException {
        return userService.getUserByMobile(mobile);
    }

    @Override
    public void sendLoginVerifyCode(String code, String mobile) throws RequestException {
        smsService.sendLoginVerifyCode(code, mobile);
    }

    @Override
    public String test_string(String a, String b) throws RequestException {
        throw MyException.makeException("asd", "dfg");
    }
}
